/* "@BEGIN_OF_SOURCE_CODE" */
#include<iostream>
#include<string.h>
#include<stdlib.h>
#define MAX 100

using namespace std;

char minesMap[MAX+1][MAX+1]={'x'};
int resultMap[MAX+1][MAX+1]={0};
int n, m;

void print()
{
	for(int i=0; i<n; i++) {
        for(int j=0; j<m; j++) {
            if(resultMap[i][j] == -1)
                cout << "*";
            else
               cout << resultMap[i][j];
        }
        if(i != (n))
           cout << endl;
     }	
}

void solve(int i, int j)
{
	if(minesMap[i][j] == 'x')
		return; 
	if(minesMap[i][j] == '*') {
		resultMap[i][j] = -1;
		return;
	}
	else {
         if(minesMap[i-1][j-1] == '*')
             resultMap[i][j]++;
         if(minesMap[i][j-1]  == '*')
             resultMap[i][j]++;
         if(minesMap[i+1][j-1] == '*') 
             resultMap[i][j]++;
         if(minesMap[i-1][j] == '*')
             resultMap[i][j]++;
         if(minesMap[i+1][j] == '*')
             resultMap[i][j]++;
         if(minesMap[i-1][j+1] == '*')
             resultMap[i][j]++;
         if(minesMap[i][j+1] == '*')
             resultMap[i][j]++;
         if(minesMap[i+1][j+1] == '*')
             resultMap[i][j]++;
	}
}

void read()
{
	int counter = 1;
	cin >> n >> m;
	while (1) {
		for(int i=0; i<n; i++) {
    		int j = 0;
    		while(j<m) {
				char tmp;
        		cin >> tmp;
            	if(tmp != '\n')
            		minesMap[i][j] = tmp;
           		else
           		   continue;
            	j++;
        	}
    	}
		for(int i=0; i<n; i++) 
			for(int j=0; j<m; j++) 
				solve(i, j);
		
		cout << "Field #" << counter++ << ":" << endl;
		print();
		cin >> n >> m;
		if(n == 0 && m == 0)
			break;
        cout << endl;
        memset(minesMap, 'x', sizeof(minesMap));
		memset(resultMap, 0,  sizeof(resultMap));
	}
}

int main()
{
	read();
	return 0;
}
